package com.atguigu.shiwu;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * Title: ShiWu
 * Description: TODO
 *
 * @author gejx
 * @version V1.0
 * @date 2021-12-08
 */
@Component
@Transactional
public class ShiWu {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void test(){
        String sql ="update user set  age=(age-?) WHERE id=?;";
        String sql1 ="update user set  age=(age+?) WHERE id=?;";
        jdbcTemplate.update(sql,1,1);
        jdbcTemplate.update(sql1,1,2);
    }

}
